#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

static void* thread_func(void* arg)
{
  char *s = (char*)arg;
  printf("%s",s);
  return (void*)strlen(s);
}

int main(int argc, char *argv[])
{
  pthread_t t1;
  void *res;
  int s;
  char str[] = "Hello world\n";
  s = pthread_create(&t1, NULL,thread_func,str);
  if (s != 0)
    printf("Failed to pthread_create\n");

  printf("Message from main()\n");
  s = pthread_join(t1,&res);
  if (s != 0)
    printf("Failed to pthread_join\n");

  printf("Thread returned %ld\n",(long)res);
  exit(EXIT_SUCCESS);
}
